home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / gmice.com / MOUSE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-12  |  4.2 KB  |  190 lines

  1. /* $Header:   C:/SRC/MOUSE/PVCS/MOUSE.C_V   1.1   12 Jun 1989 21:36:54  $
  2.     Dwight N. Tovey (Adapted from the May/June 1988 issue of TURBO TECHNIX.)
  3. -----------------------------------------------------------------------------
  4.  
  5. $Log:   C:/SRC/MOUSE/PVCS/MOUSE.C_V  $
  6. /* 
  7. /*    Rev 1.1   12 Jun 1989 21:36:54
  8. /* Corrected minor typos.
  9. /* 
  10. /* 
  11. /*    Rev 1.0   22 May 1989 13:57:50
  12. /* Initial revision.
  13. */
  14.  
  15. #include    "mouse.h"
  16.  
  17. /* STATIC REGISTERS USED THROUGHOUT */
  18. union REGS    m_inreg, m_outreg;
  19.  
  20. /* Define int for mouse device driver */
  21. #define callMDD int86( 0x33, &m_inreg, &m_outreg )
  22.  
  23.  
  24. /******  M __ R E S E T  ******/
  25. resetRec *m_reset()
  26. {
  27.     static resetRec M;
  28.  
  29.     m_inreg.x.ax = 0;                              /* Function 0. */
  30.     callMDD;
  31.     M.exists = m_outreg.x.ax;
  32.     M.nButtons = m_outreg.x.bx;
  33.     return( &M );
  34. }
  35.  
  36. /******  M __ S H O W  ******/
  37. void m_show( void )
  38. {
  39.     m_inreg.x.ax = 1;                            /* Function 1. */
  40.     callMDD;
  41. }
  42.  
  43. /******  M __ H I D E  ******/
  44. void m_hide( void )
  45. {
  46.     m_inreg.x.ax = 2;                            /* Function 2. */
  47.     callMDD;
  48. }
  49.  
  50. /******  M __ P O S  ******/
  51. LocRec *m_pos( void )
  52. {
  53.     static LocRec M;
  54.  
  55.     m_inreg.x.ax = 3;                            /* Function 3. */
  56.     callMDD;
  57.     M.buttonStatus = m_outreg.x.bx;
  58.     M.column = m_outreg.x.cx;
  59.     M.row = m_outreg.x.dx;
  60.     return( &M );
  61. }
  62.  
  63. /******  M __ M O V E T O  ******/
  64. void m_moveto( int newCol, int newRow )
  65. {
  66.     m_inreg.x.ax = 4;                            /* Function 4. */
  67.     m_inreg.x.cx = newCol;
  68.     m_inreg.x.dx = newRow;
  69.     callMDD;
  70. }
  71.  
  72. /******  M __ P R E S S E D  ******/
  73. LocRec *m_pressed( int button)
  74. {
  75.     static LocRec M;
  76.  
  77.     m_inreg.x.ax = 5;                            /* Function 5. */
  78.     m_inreg.x.bx = button;                    /* Request for specific button. */
  79.     callMDD;
  80.     M.buttonStatus = m_outreg.x.ax;
  81.     M.opCount = m_outreg.x.bx;
  82.     M.column = m_outreg.x.cx;
  83.     M.row = m_outreg.x.dx;
  84.     return( &M );
  85. }
  86.  
  87. /******  M __ R E L E A S E D  ******/
  88. LocRec *m_released( int button )
  89. {
  90.     static LocRec M;
  91.  
  92.     m_inreg.x.ax = 6;                            /* Function 6. */
  93.     m_inreg.x.bx = button;                    /* Request for specific button. */
  94.     callMDD;
  95.     M.buttonStatus = m_outreg.x.ax;
  96.     M.opCount = m_outreg.x.bx;
  97.     M.column = m_outreg.x.cx;
  98.     M.row = m_outreg.x.dx;
  99.     return( &M );
  100. }
  101.  
  102. /******  M __ C O L __ R A N G E  ******/
  103. void m_col_range( int hmin, int hmax )
  104. {
  105.     m_inreg.x.ax = 7;                            /* Function 7. */
  106.     m_inreg.x.cx = hmin;
  107.     m_inreg.x.dx = hmax;
  108.     callMDD;
  109. }
  110.  
  111. /******  M __ R O W __ R A N G E  ******/
  112. void m_row_range( int vmin, int vmax )
  113. {
  114.     m_inreg.x.ax = 8;                            /* Function 8. */
  115.     m_inreg.x.cx = vmin;
  116.     m_inreg.x.dx = vmax;
  117.     callMDD;
  118. }
  119.  
  120. /******  M __ G R A P H __ C U R S O R  ******/
  121. void m_graph_cursor( int hHot, int vHot, unsigned maskSeg, unsigned maskOfs )
  122. {
  123.     struct SREGS seg;
  124.  
  125.     m_inreg.x.ax = 9;                            /* Function 9. */
  126.     m_inreg.x.bx = hHot;                        /* Cursor hot spot: horizontal. */
  127.     m_inreg.x.cx = vHot;                        /* Cursor hot spot: vertical. */
  128.     m_inreg.x.dx = maskOfs;
  129.     seg.es = maskSeg;
  130.     int86x( 0x33, &m_inreg, &m_outreg, &seg );
  131. }
  132.  
  133. /******  M __ T E X T __ C U R S O R  ******/
  134. void m_text_cursor( int curstype, unsigned arg1, unsigned arg2 )
  135. {
  136.     m_inreg.x.ax = 10;                        /* Function 10. */
  137.     m_inreg.x.bx = curstype;
  138.     m_inreg.x.cx = arg1;
  139.     m_inreg.x.dx = arg2;
  140.     callMDD;
  141. }
  142.  
  143. /******  M __ M O T I O N  ******/
  144. moveRec *m_motion( void )
  145. {
  146.     static moveRec M;
  147.  
  148.     m_inreg.x.ax = 11;                        /* Function 11. */
  149.     callMDD;
  150.     M.hCount = m_outreg.x.cx;                /* Net horizontal. */
  151.     M.vCount = m_outreg.x.dx;                /* Net vertical. */
  152.     return( &M );
  153. }
  154.  
  155. /******  M __ I N S T __ T A S K  ******/
  156. void m_inst_task( unsigned mask, unsigned taskSeg, unsigned taskOfs )
  157. {
  158.     struct SREGS seg;
  159.  
  160.     m_inreg.x.ax = 12;                  /* Function 12. */
  161.     m_inreg.x.cx = mask;
  162.     m_inreg.x.dx = taskOfs;
  163.     seg.es = taskSeg;
  164.  
  165.     int86x( 0x33, &m_inreg, &m_outreg, &seg );
  166. }
  167.  
  168. /******  M __ L P E N __ O N  ******/
  169. void m_lpen_on( void )
  170. {
  171.     m_inreg.x.ax = 13;                        /* Function 13. */
  172.     callMDD;
  173. }
  174.  
  175. /******  M __ L P E N __ O F F  ******/
  176. void m_lpen_off( void )
  177. {
  178.     m_inreg.x.ax = 14;                        /* Function 14. */
  179.     callMDD;
  180. }
  181.  
  182. /******  M __ R A T I O  ******/
  183. void m_ratio( int horiz, int vert )
  184. {
  185.     m_inreg.x.ax = 15;                        /* Function 15. */
  186.     m_inreg.x.cx = horiz;
  187.     m_inreg.x.dx = vert;
  188.     callMDD;
  189. }
  190.